import React from 'react'
import { Routes, Route, BrowserRouter,Navigate} from 'react-router-dom'
import Login from '../views/login/Login'
import NewsSandBox from '../views/sandbox/NewsSandBox'
import News from '../views/news/News'
import Detail from '../views/news/Detail'
function IndexRouter() {
  return (
    <BrowserRouter>
      <Routes>
        <Route path="/login" element={<Login />}></Route>
        <Route path="/*" element={localStorage.getItem("token")?<NewsSandBox />:<Navigate to="/login"></Navigate>}></Route>
        <Route path="/news" element={<News />}></Route>
        <Route path="/detail/:id" element={<Detail />}></Route>
      </Routes>
    </BrowserRouter>
  )
}
export default IndexRouter
